package cn.kuang.controller;

import cn.kuang.config.ServerConfig;
import cn.kuang.utils.IPutils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author 徽州大都督
 * @date 2020/7/19
 */
@RestController
@RequestMapping("comment")
public class CommontController {

    /*@Autowired
    private ServerConfig config;*/

    /**
     * 获取登陆ip
     * @param request
     * @return
     * @throws UnknownHostException
     */
    @RequestMapping("getId")
    public String getId(HttpServletRequest request) throws UnknownHostException {
        InetAddress address = InetAddress.getLocalHost();
        return address.getHostAddress(); //返回IP地址
    }
}
